<?php
/*
 * 模块问题分文件处理
 * @package
 * @author     Mark
 * @copyright  Copyright (c) 2013 ixdcw team
 * @version    $Id: 0ae7f3ae1e4041877a2264cb9102cbcf7a2a3772 $
 */
defined('IN_IXDCW') or exit('Access Denied');
$mid = isset($mid) ? intval($mid) : 0;
if (!$_edittime) {
	dheader(url('member/edit', 'needFull'));
}
if($mid) {
	// 如果是模块则加载模块的配置

	/** @var $MST member setting 会员组设置 */
	$MST = PCache::read('module-2.php');

	isset($admin_user) or $admin_user = false;

	/** @var $show_oauth 一键登录 */
	$show_oauth = $MST['oauth'];

	/** @var $show_menu 会员个人资料中心显示所有菜单 */
	if(!$_userid) $action = 'add';//Guest

	if($_groupid > 5 && !$_edittime && ($action == 'add'||$action == 'addonline')) dheader('edit.php?tab=2');
	if($_groupid > 4 && (($MST['vemail'] && $MG['vemail']) || ($MST['vmobile'] && $MG['vmobile']) || ($MST['vtruename'] && $MG['vtruename']) || ($MST['vcompany'] && $MG['vcompany']))) {
		$V = $db->getOne("SELECT vemail,vmobile,vtruename,vcompany FROM {$db->getPre()}member WHERE userid=$_userid");
		// 会员设置邮件认证, 会员组设置邮件强制认证

		if($MST['vemail'] && $MG['vemail']) {
			$V['vemail'] or dheader('validate.php?action=email&itemid=1');
		}

		if($MST['vmobile'] && $MG['vmobile']) {
			$V['vmobile'] or dheader('validate.php?action=mobile&itemid=1');
		}

		if($MST['vtruename'] && $MG['vtruename']) {
			$V['vtruename'] or dheader('validate.php?action=truename&itemid=1');
		}

		if($MST['vcompany'] && $MG['vcompany']) {
			$V['vcompany'] or dheader('validate.php?action=company&itemid=1');
		}

	}

	// 提交检测禁止词
	if($submit) {
		Env::checkPost() or Prompt::alert($L['bad_data']);//safe
		$BANWORD = PCache::read('banword.php');
		if($BANWORD && isset($post)) {
			$keys = array('title', 'tag', 'introduce', 'content');
			foreach($keys as $v) {
				if(isset($post[$v])) $post[$v] = banword($BANWORD, $post[$v]);
			}
		}
	}

	// 我的允许发布信息的模块 MY MODULES
	$MYMODS = array();
	if(isset($MG['moduleids']) && $MG['moduleids']) {
		$MYMODS = explode(',', $MG['moduleids']);
	}
	if($MYMODS) {
		foreach($MYMODS as $k=>$v) {
			$v = abs($v);
			if(!isset($MODULE[$v]) || $v<=4) unset($MYMODS[$k]);
		}
	}


	$vid = $mid;
	if($mid == 9 && isset($resume)) $vid = -9;

	// 验证服务模块
	if( !$MYMODS || !(in_array($vid, $MYMODS) || $vid ==30) )
		Prompt::message('', url('member/my'));

	$IMVIP = isset($MG['vip']) && $MG['vip'];
	$moduleid = $mid;
	$module = $MODULE[$moduleid]['module'];
	if(!$module) Prompt::message();
	$MOD = PCache::read('module-'.$moduleid.'.php');

	$my_file = DT_CORE.'/'.$module.'/my.inc.php';
	$userInfo = userinfo($_username);
	if(is_file($my_file)) {
		require $my_file;
	} else {
		dheader(url('member/index'));
	}
}
require DT_CORE.'/'.$module.'/common.inc.php';
$head_title = $action == 'add' ? $L['info_add'] : $L['info_manage'];
include template('my', $module);